<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>课程审核</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <style>
        .box{
            padding: 10px 50px 0px 50px;
        }
        .layui-layedit{
            margin-left: 76px;
        }
        .buttonBox{
            margin-left: 500px;
        }
        form p{
            margin-top: 30px;
        }

        #confirm{
            background-color: #1E9FFF;
            color: #FFFFFF;
        }
    </style>
</head>
<body>
    <div id="app" class="box">
        <form class="layui-form">
            <p id="courseName"></p>
                <input name="result" id="result" type="hidden" />
                <input name="courseId" id="courseId" type="hidden" />
                <input name="implementId" id="implementId" type="hidden" />
                <input name="implementDate" id="implementDate" type="hidden" />
            <p id="check">
                课程审核：
                <input name="auditResult" type="radio" lay-filter="check" title="审核通过" value="审核通过"/>
                <input name="auditResult" type="radio" lay-filter="check" title="审核不通过" value="审核不通过" />
            </p>
            <p>
                反馈详情：
                <div class="layui-form-text">
                    <div class="layui-input-inline" >
                        <textarea name="remarks" placeholder="请输入内容" lay-verify="content"  id="demo_editor" class="layui-textarea" ></textarea>
                    </div>
                </div>
            </p>
            <div class="buttonBox">
                <input type="submit" lay-submit lay-filter="confirm" class="layui-btn" value="确定" id="confirm" />
                <input type="button" class="layui-btn layui-btn-primary" value="取消" id="cancel" />
            </div>
        </form>
    </div>
</body>
<script>
    layui.use(['jquery','layer','form','layedit'],function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var layedit = layui.layedit;
        var implementDate = "";//创建时间
        var editor = layedit.build('demo_editor',{
            height: 150 //设置编辑器高度
        });
        form.verify({
            //content富文本域中的lay-verify值
            content: function(value) {
                return layedit.sync(editor);
            }
        });
        //关闭按钮点击事件
        $('#cancel').click(function () {
            var layer = parent.layer;
            layer.close(layer.index);
        });

        //给执行人赋值
        var user = JSON.parse(localStorage.getItem("user"));
        $('#implementId').val(user.data.userId);
        //给执行时间赋值
        //现在时间

        function getTime(){
            var date=new Date();
            var year=date.getFullYear();
            var month=date.getMonth()+1;
            var day=date.getDate();
            var hour=date.getHours();
            var minute=date.getMinutes();
            var second=date.getSeconds();
            var dateStr = year+"-"+zeroFilling(month)+"-"+zeroFilling(day)+" "+zeroFilling(hour)+":"+zeroFilling(minute)+":"+zeroFilling(second);
            implementDate = dateStr;
        }
        function zeroFilling(data){
            if(data<10){
                data="0"+data;
            }
            return data;
        }

        //确定按钮点击
        form.on('submit(confirm)',function (data) {
            getTime();
            if(data.field.auditResult=="审核通过"){
                $("#result").val(1);
            }else if(data.field.auditResult=="审核不通过"){
                $("#result").val(3);
            }
            var result = $("#result").val();

            var param = {
                "courseId": data.field.courseId,
                "implementId": data.field.implementId,
                "implementDate":implementDate,
                "result": result,
                "remarks": data.field.remarks,
            }
            //修改审核状态
            $.ajax({
                url: '/course/courseExamine',
                data: param,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            });
            var params = {
                "examineType": 2,
                "type": result,
                "userId":user.data.userId,
                "createDate":implementDate,
                "remark": data.field.remarks,
                "examineId": data.field.courseId,
                "userName": user.data.trueName,
            }
            //添加审核日志
            $.ajax({
                url: '/course/addCourseauditLog',
                data: params,
                type: 'post',
                dataType: 'json',
                success: function (data) {

                }
            });

            var layer = parent.layer;
            layer.close(layer.index);
            return false;

        });
    })

</script>
</html>